home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
movedir.arc
/
MOVEDIR.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1986-12-11
|
2KB
|
53 lines
Program MoveDir;
TYPE
CommandStr = STRING[127];
Str80 = STRING[80];
Registers = RECORD CASE Integer OF
1 : (AX, BX, CX, DX, BP, SI, DI, DS, ES, FLAGS : Integer);
2 : (AL, AH, BL, BH, CL, CH, DL, DH : Byte);
END; {of case}
VAR
OrgName, NewName :Str80;
Error : Integer;
PROCEDURE Move_Dir (VAR Orgn, Newn : Str80; VAR ER : Integer);
VAR Regs : Registers;
BEGIN
WITH Regs DO
BEGIN
AH := $56; {Dos function $56}
DS := Seg(Orgn); {address of original name}
DX := Ofs(Orgn)+1;
ES := Seg(NewN); {address of new name}
DI := Ofs(NewN)+1;
MsDos(Regs);
IF Flags AND 1 = 1 THEN ER := AX
ELSE ER := 0;
END;
END;
PROCEDURE Move_Dir2 (VAR Orgn, Newn : Str80; VAR ER : Integer);
(* Uses Turbo's Own Rename procedure to change a file's directory *)
VAR F : file;
BEGIN
Assign(F,Orgn);
{$I-} Rename(F,NewN); {$I+}
ER := IOresult;
END;
BEGIN
IF ParamCount = 2 THEN
BEGIN
OrgName := ParamStr(1)+Chr(0);
NewName := ParamStr(2)+Chr(0);
Move_Dir2(OrgName, Newname, Error);
CASE Error OF
0 : Writeln('Successfully moved ',OrgName,' to ',NewName);
2 : Writeln('File Not found.');
3 : Writeln('Path not found.');
5 : Writeln('File Access Denied');
ELSE Writeln('Error #',Error);
END;
END
ELSE Writeln(#7, 'Enter "MOVEDIR <oldpathname> <newpathname>"');
END.